#taken from http://www.daniweb.com/forums/thread70647.html

# using module re to pluralize most common english words
# (rule_tuple used as function default, so establish it first)
 
import re
 
# (pattern, search, replace) regex english plural rules tuple
rule_tuple = (
	('[ml]ouse$', '([ml])ouse$', '\\1ice'),
	('booth$', 'booth$', 'booths'),
	('foot$', 'foot$', 'feet'),
	('ooth$', 'ooth$', 'eeth'),
	('l[eo]af$', 'l([eo])af$', 'l\\1aves'),
	('sis$', 'sis$', 'ses'),
	('man$', 'man$', 'men'),
	('ife$', 'ife$', 'ives'),
	('eau$', 'eau$', 'eaux'),
	('lf$', 'lf$', 'lves'),
	('[sxz]$', '$', 'es'),
	('[^aeioudgkprt]h$', '$', 'es'),
	('(qu|[^aeiou])y$', 'y$', 'ies'),
	('$', '$', 's')
	)
 
def regex_rules(rules=rule_tuple):
	for line in rules:
		pattern, search, replace = line
		yield lambda word: re.search(pattern, word) and re.sub(search, replace, word)
 
def plural(noun):
	for rule in regex_rules():
		result = rule(noun)
		if result:
			return result 